function getXMLHTTPRequestObj(){
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        return null;
    }
}
function validateTlf(tlf){
    var ajax = getXMLHTTPRequestObj();
    ajax.open("POST","../NewCustomer/tlf.jsp?req="+tlf,true);
    ajax.send();
    ajax.onreadystatechange=function(){
        document.getElementById("valid_tlf").innerHTML = ajax.readyState;
        if (ajax.readyState==4 && ajax.status==200){
            document.getElementById("valid_tlf").innerHTML = ajax.responseText;
        }
    }
}
function updateModelsByMake(makes){
    var ajax = getXMLHTTPRequestObj();
    //var makes = document.getElementById("makes").value;
    ajax.open("POST","updateModels.jsp?req="+makes,true);
    ajax.send();
    ajax.onreadystatechange=function()
    {
        try{
            document.getElementById("model").innerHTML = ajax.readyState;
            if (ajax.readyState==4 && ajax.status==200){
                document.getElementById("model").innerHTML = ajax.responseText;
            } else{
                document.getElementById("model").innerHTML = "Henter modeller... ";
            }
        }catch(ex){
            document.getElementById("model").innerHTML = "Fejl...";
        }
    }
}
function combineCars(models){
    var ajax = getXMLHTTPRequestObj();
    ajax.open("POST","updateCars.jsp?models="+models,true);
    ajax.send();
    ajax.onreadystatechange=function()
    {
        try{
            document.getElementById("cars").innerHTML = ajax.readyState;
            if (ajax.readyState==4 && ajax.status==200){
                document.getElementById("cars").innerHTML = ajax.responseText;
            } else{
                document.getElementById("cars").innerHTML = "Kombinere biler... ";
            }
        }catch(ex){
            document.getElementById("cars").innerHTML = "Fejl...";
        }
    }
}

